home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / DDJ0992.ARJ / LISTS.C < prev    next >
Text File  |  1992-07-11  |  3KB  |  125 lines

  1. /* --------------- lists.c -------------- */
  2.  
  3. #include "dflat.h"
  4.  
  5. /* ----- set focus to the next sibling ----- */
  6. void SetNextFocus()
  7. {
  8.     if (inFocus != NULL)    {
  9.         WINDOW wnd1 = inFocus, pwnd;
  10.         while (TRUE)    {
  11.             pwnd = GetParent(wnd1);
  12.             if (NextWindow(wnd1) != NULL)
  13.                 wnd1 = NextWindow(wnd1);
  14.             else if (pwnd != NULL)
  15.                 wnd1 = FirstWindow(pwnd);
  16.             if (wnd1 == NULL || wnd1 == inFocus)    {
  17.                 wnd1 = pwnd;
  18.                 break;
  19.             }
  20.             if (GetClass(wnd1) == STATUSBAR || GetClass(wnd1) == MENUBAR)
  21.                 continue;
  22.             if (isVisible(wnd1))
  23.                 break;
  24.         }
  25.         if (wnd1 != NULL)    {
  26.             while (wnd1->childfocus != NULL)
  27.                 wnd1 = wnd1->childfocus;
  28.             if (wnd1->condition != ISCLOSING)
  29.                 SendMessage(wnd1, SETFOCUS, TRUE, 0);
  30.         }
  31.     }
  32. }
  33.  
  34. /* ----- set focus to the previous sibling ----- */
  35. void SetPrevFocus()
  36. {
  37.     if (inFocus != NULL)    {
  38.         WINDOW wnd1 = inFocus, pwnd;
  39.         while (TRUE)    {
  40.             pwnd = GetParent(wnd1);
  41.             if (PrevWindow(wnd1) != NULL)
  42.                 wnd1 = PrevWindow(wnd1);
  43.             else if (pwnd != NULL)
  44.                 wnd1 = LastWindow(pwnd);
  45.             if (wnd1 == NULL || wnd1 == inFocus)    {
  46.                 wnd1 = pwnd;
  47.                 break;
  48.             }
  49.             if (GetClass(wnd1) == STATUSBAR)
  50.                 continue;
  51.             if (isVisible(wnd1))
  52.                 break;
  53.         }
  54.         if (wnd1 != NULL)    {
  55.             while (wnd1->childfocus != NULL)
  56.                 wnd1 = wnd1->childfocus;
  57.             if (wnd1->condition != ISCLOSING)
  58.                 SendMessage(wnd1, SETFOCUS, TRUE, 0);
  59.         }
  60.     }
  61. }
  62.  
  63. /* ------- move a window to the end of its parents list ----- */
  64. void ReFocus(WINDOW wnd)
  65. {
  66.     if (GetParent(wnd) != NULL)    {
  67.         RemoveWindow(wnd);
  68.         AppendWindow(wnd);
  69.         ReFocus(GetParent(wnd));
  70.     }
  71. }
  72.  
  73. /* ---- remove a window from the linked list ---- */
  74. void RemoveWindow(WINDOW wnd)
  75. {
  76.     if (wnd != NULL)    {
  77.         WINDOW pwnd = GetParent(wnd);
  78.         if (PrevWindow(wnd) != NULL)
  79.             NextWindow(PrevWindow(wnd)) = NextWindow(wnd);
  80.         if (NextWindow(wnd) != NULL)
  81.             PrevWindow(NextWindow(wnd)) = PrevWindow(wnd);
  82.         if (pwnd != NULL)    {
  83.             if (wnd == FirstWindow(pwnd))
  84.                 FirstWindow(pwnd) = NextWindow(wnd);
  85.             if (wnd == LastWindow(pwnd))
  86.                 LastWindow(pwnd) = PrevWindow(wnd);
  87.         }
  88.     }
  89. }
  90.  
  91. /* ---- append a window to the linked list ---- */
  92. void AppendWindow(WINDOW wnd)
  93. {
  94.     if (wnd != NULL)    {
  95.         WINDOW pwnd = GetParent(wnd);
  96.         if (pwnd != NULL)    {
  97.             if (FirstWindow(pwnd) == NULL)
  98.                 FirstWindow(pwnd) = wnd;
  99.             if (LastWindow(pwnd) != NULL)
  100.                 NextWindow(LastWindow(pwnd)) = wnd;
  101.             PrevWindow(wnd) = LastWindow(pwnd);
  102.             LastWindow(pwnd) = wnd;
  103.         }
  104.         NextWindow(wnd) = NULL;
  105.     }
  106. }
  107.  
  108. /* ----- if document windows and statusbar or menubar get the focus,
  109.               pass it on ------- */
  110. void SkipApplicationControls(void)
  111. {
  112.     BOOL EmptyAppl = FALSE;
  113.     int ct = 0;
  114.     while (!EmptyAppl && inFocus != NULL)    {
  115.         CLASS cl = GetClass(inFocus);
  116.         if (cl == MENUBAR || cl == STATUSBAR)    {
  117.             SetPrevFocus();
  118.             EmptyAppl = (cl == MENUBAR && ct++);
  119.         }
  120.         else
  121.             break;
  122.     }
  123. }
  124.  
  125.